package com.cgwx.commonutils.math.function;

import com.cgwx.commonutils.math.PascalsTriangle;

/**
 * @author GaoWei
 * @Date 2021/8/6 - 9:48
 */
public class CombinFunction implements Function
{
    @Override
    public double of(double[] d, int numParam)
    {
        int n = (int)d[0];
        int r = (int)d[1];
        return PascalsTriangle.nCr(n, r);
    }

    @Override
    public boolean acceptNumParam(int numParam)
    {
        return numParam == 2;
    }

    public String toString()
    {
        return "combin(n, r)";
    }
}
